
/****** Object:  StoredProcedure [dbo].[web_ins_upd_ws_users]    Script Date: 10/19/2013 09:20:36 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'web_ins_upd_ws_users')
DROP PROCEDURE web_ins_upd_ws_users
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[web_ins_upd_ws_users]
	@uid varchar(12),
	@pav varchar(60),
	@role_id varchar(30),
	@pass varchar(16),
	@apzvalga char(1)
AS
BEGIN
	SET NOCOUNT ON
	

	If exists(SELECT * FROM ws_users where aparatoid = cast(@uid as int))
		update ws_users set role_id = @role_id,user_id=@pass where aparatoid = cast(@uid as int)
	else
		insert into ws_users (aparatoid,role_id,user_id) values (cast(@uid as int),@role_id,@pass)

    update aparatai set apzvalga=@apzvalga,aparatopavadinimas = @pav where aparatoid = cast(@uid as int)
END

GO



